
import {get_order_pay} from '../../../api/other'
import { submitOrderDepictPay} from "../../../api/order";

Page({
  data: {
    id: '',
    data:{}
  },
  onLoad(e) {
    console.log(e)
    if (e.order_id) {
      this.setData({
        id: e.order_id
      })
      this.get_list()
    }
  },
  handleClick() {
    submitOrderDepictPay({order_id:this.data.id}).then(res => {
      if (res.trade_no) {
        my.tradePay({
          tradeNO: res.trade_no,
          success: (res) => {
            if (res.resultCode == 9000) {
              my.navigateBack();
            } else {
              my.showToast({
                type: 'fail',
                content: '支付失败，请稍后重试',
                duration: 1000,
              });
            }
          }
        });
      }
    })
  },
  async get_list() {
    console.log( );
    const res = await get_order_pay({order_id:this.data.id})
    if(res) {
      console.log(res)
      this.setData({
        data: res
      })
  
    }
  }
});